package test;

import com.alibaba.fastjson.JSONObject;
import test.exception.ValidateException;

/**
 * Created by Administrator on 2016/9/26.
 */
public class BaseResult {
    private String code ;
    private Object data;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static void addSuccess(Object object){
        BaseResult br = new BaseResult();
        br.setCode("1000");
        br.setData(object);
        String s = JSONObject.toJSONString(br);
        throw new ValidateException(s);
    }
    public static void addError(String errKey,String errMsg){
        BaseResult br = new BaseResult();
        br.setCode(errKey);
        br.setData(errMsg);
        String s = JSONObject.toJSONString(br);
        throw new ValidateException(s);
    }


}
